package com.mebs.edi.model.edi;

import java.sql.Time;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.mebs.edi.model.dom.DomAttribute;
import com.mebs.edi.model.dom.DomChildren;
import com.mebs.edi.model.dom.DomEntity;

/**
 * 
 * ISA + IEA sections of a EDI file 
 * 
 * @author nit
 *
 */
@Entity()
@Table(name = "edi_isa")
@DomEntity(name = "ISA")
public class EdiIsa {
	
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "Id")
	private Long id;
	
	@OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name="isa_id")
	@DomChildren
	private List<EdiGs> gs;
	
	@Column(nullable = true, length = 2)
	@DomAttribute
	private String isa01; 		// Authorization Info Qual.
	
	@Column(nullable = true, length = 10)
	@DomAttribute
	private String isa02; 		// Authorization Information
	
	@Column(nullable = true, length = 2)
	@DomAttribute
	private String isa03; 		// Security Info Qual.
	
	@Column(nullable = true, length = 10)
	@DomAttribute
	private String isa04; 		// Security Information
	
	@Column(nullable = true, length = 2)
	@DomAttribute
	private String isa05; 		// Interchange ID Qual.
	
	@Column(nullable = true, length = 15)
	@DomAttribute
	private String isa06; 		// Interchange Sender ID
	
	@Column(nullable = true, length = 2)
	@DomAttribute
	private String isa07; 		// Interchange ID Qualifier
	
	@Column(nullable = true, length = 15)
	@DomAttribute
	private String isa08; 		// Interchange Receiver ID
	
	@Column(nullable = true)
	@DomAttribute
	private Date isa09; 		// Interchange Date
	
	@Column(nullable = true)
	@DomAttribute
	private Time isa10; 		// Interchange Time
	
	@Column(nullable = true)
	@DomAttribute
	private Character isa11; 	// Interchange Control Standard Identifier
	
	@Column(nullable = true, length = 5)
	@DomAttribute
	private String isa12; 		// Interchange Control Version Number
	
	@Column(nullable = true, length = 9)
	@DomAttribute
	private String isa13; 		// Interchange Control Number
	
	@Column(nullable = true)
	@DomAttribute
	private Byte isa14; 		// Acknowledgment Requested
	
	@Column(nullable = true)
	@DomAttribute
	private Character isa15; 	// Usage Indicator
	
	@Column(nullable = true)
	@DomAttribute
	private Character isa16; 	// Component Element Separator
	
	@Column(nullable = true)
	@DomAttribute
	private Integer iea01; 		// Number of Included Functional Groups
	
	@Column(nullable = true, length = 9)
	@DomAttribute
	private String iea02; 		// Interchange Control Number
	
	public EdiIsa() {
		super();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getIsa01() {
		return isa01;
	}

	public void setIsa01(String isa01) {
		this.isa01 = isa01;
	}

	public String getIsa02() {
		return isa02;
	}

	public void setIsa02(String isa02) {
		this.isa02 = isa02;
	}

	public String getIsa03() {
		return isa03;
	}

	public void setIsa03(String isa03) {
		this.isa03 = isa03;
	}

	public String getIsa04() {
		return isa04;
	}

	public void setIsa04(String isa04) {
		this.isa04 = isa04;
	}

	public String getIsa05() {
		return isa05;
	}

	public void setIsa05(String isa05) {
		this.isa05 = isa05;
	}

	public String getIsa06() {
		return isa06;
	}

	public void setIsa06(String isa06) {
		this.isa06 = isa06;
	}

	public String getIsa07() {
		return isa07;
	}

	public void setIsa07(String isa07) {
		this.isa07 = isa07;
	}

	public String getIsa08() {
		return isa08;
	}

	public void setIsa08(String isa08) {
		this.isa08 = isa08;
	}

	public Date getIsa09() {
		return isa09;
	}

	public void setIsa09(Date isa09) {
		this.isa09 = isa09;
	}

	public Time getIsa10() {
		return isa10;
	}

	public void setIsa10(Time isa10) {
		this.isa10 = isa10;
	}

	public Character getIsa11() {
		return isa11;
	}

	public void setIsa11(Character isa11) {
		this.isa11 = isa11;
	}

	public String getIsa12() {
		return isa12;
	}

	public void setIsa12(String isa12) {
		this.isa12 = isa12;
	}

	public String getIsa13() {
		return isa13;
	}

	public void setIsa13(String isa13) {
		this.isa13 = isa13;
	}

	public Byte getIsa14() {
		return isa14;
	}

	public void setIsa14(Byte isa14) {
		this.isa14 = isa14;
	}

	public Character getIsa15() {
		return isa15;
	}

	public void setIsa15(Character isa15) {
		this.isa15 = isa15;
	}

	public Character getIsa16() {
		return isa16;
	}

	public void setIsa16(Character isa16) {
		this.isa16 = isa16;
	}

	public Integer getIea01() {
		return iea01;
	}

	public void setIea01(Integer iea01) {
		this.iea01 = iea01;
	}

	public String getIea02() {
		return iea02;
	}

	public void setIea02(String iea02) {
		this.iea02 = iea02;
	}

	public List<EdiGs> getGs() {
		return gs;
	}

	public void setGs(List<EdiGs> gs) {
		this.gs = gs;
	}

	@Override
	public String toString() {
		return "EdiIsa [id=" + id + ", gs=" + gs + ", isa01=" + isa01 + ", isa02=" + isa02 + ", isa03="
				+ isa03 + ", isa04=" + isa04 + ", isa05=" + isa05 + ", isa06=" + isa06 + ", isa07=" + isa07
				+ ", isa08=" + isa08 + ", isa09=" + isa09 + ", isa10=" + isa10 + ", isa11=" + isa11
				+ ", isa12=" + isa12 + ", isa13=" + isa13 + ", isa14=" + isa14 + ", isa15=" + isa15
				+ ", isa16=" + isa16 + ", iea01=" + iea01 + ", iea02=" + iea02 + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((gs == null) ? 0 : gs.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((iea01 == null) ? 0 : iea01.hashCode());
		result = prime * result + ((iea02 == null) ? 0 : iea02.hashCode());
		result = prime * result + ((isa01 == null) ? 0 : isa01.hashCode());
		result = prime * result + ((isa02 == null) ? 0 : isa02.hashCode());
		result = prime * result + ((isa03 == null) ? 0 : isa03.hashCode());
		result = prime * result + ((isa04 == null) ? 0 : isa04.hashCode());
		result = prime * result + ((isa05 == null) ? 0 : isa05.hashCode());
		result = prime * result + ((isa06 == null) ? 0 : isa06.hashCode());
		result = prime * result + ((isa07 == null) ? 0 : isa07.hashCode());
		result = prime * result + ((isa08 == null) ? 0 : isa08.hashCode());
		result = prime * result + ((isa09 == null) ? 0 : isa09.hashCode());
		result = prime * result + ((isa10 == null) ? 0 : isa10.hashCode());
		result = prime * result + ((isa11 == null) ? 0 : isa11.hashCode());
		result = prime * result + ((isa12 == null) ? 0 : isa12.hashCode());
		result = prime * result + ((isa13 == null) ? 0 : isa13.hashCode());
		result = prime * result + ((isa14 == null) ? 0 : isa14.hashCode());
		result = prime * result + ((isa15 == null) ? 0 : isa15.hashCode());
		result = prime * result + ((isa16 == null) ? 0 : isa16.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EdiIsa other = (EdiIsa) obj;
		if (gs == null) {
			if (other.gs != null)
				return false;
		} else if (!gs.equals(other.gs))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (iea01 == null) {
			if (other.iea01 != null)
				return false;
		} else if (!iea01.equals(other.iea01))
			return false;
		if (iea02 == null) {
			if (other.iea02 != null)
				return false;
		} else if (!iea02.equals(other.iea02))
			return false;
		if (isa01 == null) {
			if (other.isa01 != null)
				return false;
		} else if (!isa01.equals(other.isa01))
			return false;
		if (isa02 == null) {
			if (other.isa02 != null)
				return false;
		} else if (!isa02.equals(other.isa02))
			return false;
		if (isa03 == null) {
			if (other.isa03 != null)
				return false;
		} else if (!isa03.equals(other.isa03))
			return false;
		if (isa04 == null) {
			if (other.isa04 != null)
				return false;
		} else if (!isa04.equals(other.isa04))
			return false;
		if (isa05 == null) {
			if (other.isa05 != null)
				return false;
		} else if (!isa05.equals(other.isa05))
			return false;
		if (isa06 == null) {
			if (other.isa06 != null)
				return false;
		} else if (!isa06.equals(other.isa06))
			return false;
		if (isa07 == null) {
			if (other.isa07 != null)
				return false;
		} else if (!isa07.equals(other.isa07))
			return false;
		if (isa08 == null) {
			if (other.isa08 != null)
				return false;
		} else if (!isa08.equals(other.isa08))
			return false;
		if (isa09 == null) {
			if (other.isa09 != null)
				return false;
		} else if (!isa09.equals(other.isa09))
			return false;
		if (isa10 == null) {
			if (other.isa10 != null)
				return false;
		} else if (!isa10.equals(other.isa10))
			return false;
		if (isa11 == null) {
			if (other.isa11 != null)
				return false;
		} else if (!isa11.equals(other.isa11))
			return false;
		if (isa12 == null) {
			if (other.isa12 != null)
				return false;
		} else if (!isa12.equals(other.isa12))
			return false;
		if (isa13 == null) {
			if (other.isa13 != null)
				return false;
		} else if (!isa13.equals(other.isa13))
			return false;
		if (isa14 == null) {
			if (other.isa14 != null)
				return false;
		} else if (!isa14.equals(other.isa14))
			return false;
		if (isa15 == null) {
			if (other.isa15 != null)
				return false;
		} else if (!isa15.equals(other.isa15))
			return false;
		if (isa16 == null) {
			if (other.isa16 != null)
				return false;
		} else if (!isa16.equals(other.isa16))
			return false;
		return true;
	}
}
